﻿using System;
using static System.Console;

namespace Wrox.ProCSharp.Delegates
{
    //继承自EventArgs类
  public class CarInfoEventArgs : EventArgs
  {
    public CarInfoEventArgs(string car)
    {
      Car = car;
    }

    public string Car { get; }
  }
    //事件发布程序
  public class CarDealer
  {
    //定义NewCarInfo事件
    public event EventHandler<CarInfoEventArgs> NewCarInfo;

    public void NewCar(string car)
    {
      WriteLine($"CarDealer, new car {car}");
      //触发事件
      NewCarInfo?.Invoke(this, new CarInfoEventArgs(car));
    }

  }
}
